#ifndef BLUETOOTHSERVER_H
#define BLUETOOTHSERVER_H

#include <QObject>
#include <QList>
#include <QDebug>
#include <QTimer>

#include <qbluetoothserviceinfo.h>
#include "networkmessageparser.h"

QTM_BEGIN_NAMESPACE
class QL2capServer;
class QBluetoothSocket;
QTM_END_NAMESPACE

QTM_USE_NAMESPACE

class BluetoothServer : public QObject
{
Q_OBJECT
public:
    BluetoothServer();
    ~BluetoothServer();

    Q_INVOKABLE void startServer();
    Q_INVOKABLE void stopServer();

signals:
    void socketConnected(QBluetoothSocket*);
    void socketDisconnected();

    void messageReceived(QString message);

public slots:
    void clientConnected();
    void clientDisconnected();
    void readData();

private:
    QL2capServer *l2capServer;
    QBluetoothServiceInfo serviceInfo;
    QBluetoothSocket* clientSocket;

    void handleMessage(QString message);
};

#endif // BLUETOOTHSERVER_H
